import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
restaurants=pd.read_csv('zomato.csv',encoding = "ISO-8859-1")
countrycode=pd.read_excel('Country-Code.xlsx')
restaurants.head()
| Restaurant ID | Restaurant Name | Country Code | City | Address | Locality | Locality Verbose | Longitude | Latitude | Cuisines | ... | Currency | Has Table booking | Has Online delivery | Is delivering now | Switch to order menu | Price range | Aggregate rating | Rating color | Rating text | Votes | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 6317637 | Le Petit Souffle | 162 | Makati City | Third Floor, Century City Mall, Kalayaan Avenu... | Century City Mall, Poblacion, Makati City | Century City Mall, Poblacion, Makati City, Mak... | 121.027535 | 14.565443 | French, Japanese, Desserts | ... | Botswana Pula(P) | Yes | No | No | No | 3 | 4.8 | Dark Green | Excellent | 314 |
| 1 | 6304287 | Izakaya Kikufuji | 162 | Makati City | Little Tokyo, 2277 Chino Roces Avenue, Legaspi... | Little Tokyo, Legaspi Village, Makati City | Little Tokyo, Legaspi Village, Makati City, Ma... | 121.014101 | 14.553708 | Japanese | ... | Botswana Pula(P) | Yes | No | No | No | 3 | 4.5 | Dark Green | Excellent | 591 |
| 2 | 6300002 | Heat - Edsa Shangri-La | 162 | Mandaluyong City | Edsa Shangri-La, 1 Garden Way, Ortigas, Mandal... | Edsa Shangri-La, Ortigas, Mandaluyong City | Edsa Shangri-La, Ortigas, Mandaluyong City, Ma... | 121.056831 | 14.581404 | Seafood, Asian, Filipino, Indian | ... | Botswana Pula(P) | Yes | No | No | No | 4 | 4.4 | Green | Very Good | 270 |
| 3 | 6318506 | Ooma | 162 | Mandaluyong City | Third Floor, Mega Fashion Hall, SM Megamall, O... | SM Megamall, Ortigas, Mandaluyong City | SM Megamall, Ortigas, Mandaluyong City, Mandal... | 121.056475 | 14.585318 | Japanese, Sushi | ... | Botswana Pula(P) | No | No | No | No | 4 | 4.9 | Dark Green | Excellent | 365 |
| 4 | 6314302 | Sambo Kojin | 162 | Mandaluyong City | Third Floor, Mega Atrium, SM Megamall, Ortigas... | SM Megamall, Ortigas, Mandaluyong City | SM Megamall, Ortigas, Mandaluyong City, Mandal... | 121.057508 | 14.584450 | Japanese, Korean | ... | Botswana Pula(P) | Yes | No | No | No | 4 | 4.8 | Dark Green | Excellent | 229 |
5 rows × 21 columns
restaurants.columns
Index(['Restaurant ID', 'Restaurant Name', 'Country Code', 'City', 'Address',
'Locality', 'Locality Verbose', 'Longitude', 'Latitude', 'Cuisines',
'Average Cost for two', 'Currency', 'Has Table booking',
'Has Online delivery', 'Is delivering now', 'Switch to order menu',
'Price range', 'Aggregate rating', 'Rating color', 'Rating text',
'Votes'],
dtype='object')
restaurants.rename(columns={'Restaurant ID':'Restaurant_ID', 'Restaurant Name':'Restaurant_Name', 'Country Code':'Country_Code', 'Locality Verbose':'Locality_Verbose',
'Average Cost for two':'Average_Cost_for_two', 'Has Table booking':'Has_Table_booking','Has Online delivery':'Has_Online_delivery', 'Is delivering now':'Is_delivering_now', 'Switch to order menu':'Switch_to_order_menu','Price range':'Price_range', 'Aggregate rating':'Aggregate_rating', 'Rating color':'Rating_color', 'Rating text':'Rating_text'},
inplace=True)
restaurants.shape
(9551, 21)
countrycode
| Country Code | Country | |
|---|---|---|
| 0 | 1 | India |
| 1 | 14 | Australia |
| 2 | 30 | Brazil |
| 3 | 37 | Canada |
| 4 | 94 | Indonesia |
| 5 | 148 | New Zealand |
| 6 | 162 | Phillipines |
| 7 | 166 | Qatar |
| 8 | 184 | Singapore |
| 9 | 189 | South Africa |
| 10 | 191 | Sri Lanka |
| 11 | 208 | Turkey |
| 12 | 214 | UAE |
| 13 | 215 | United Kingdom |
| 14 | 216 | United States |
countrycode.rename(columns={"Country Code":"Country_Code"}, inplace= True)
countrycode.columns
Index(['Country_Code', 'Country'], dtype='object')
restaurants["Average_Cost_for_two"][restaurants["Average_Cost_for_two"]==0]
84 0 85 0 87 0 201 0 240 0 277 0 346 0 397 0 407 0 634 0 637 0 639 0 677 0 851 0 2364 0 2368 0 9242 0 9254 0 Name: Average Cost for two, dtype: int64
The average cost for two column has some 0 values which is improper. Lets try removing those datas
restaurants['Average_Cost_for_two']=restaurants['Average_Cost_for_two'].replace(0,np.nan)
restaurants.isnull().sum()
Restaurant_ID 0 Restaurant_Name 0 Country_Code 0 City 0 Address 0 Locality 0 Locality_Verbose 0 Longitude 0 Latitude 0 Cuisines 9 Average_Cost_for_two 18 Currency 0 Has_Table_booking 0 Has_Online_delivery 0 Is_delivering_now 0 Switch_to_order_menu 0 Price_range 0 Aggregate_rating 0 Rating_color 0 Rating_text 0 Votes 0 dtype: int64
restaurants.dropna(inplace=True)
restaurants=restaurants.merge(countrycode,on='Country_Code')
restaurants.head()
| Restaurant_ID | Restaurant_Name | Country_Code | City | Address | Locality | Locality_Verbose | Longitude | Latitude | Cuisines | ... | Has_Table_booking | Has_Online_delivery | Is_delivering_now | Switch_to_order_menu | Price_range | Aggregate_rating | Rating_color | Rating_text | Votes | Country | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 6317637 | Le Petit Souffle | 162 | Makati City | Third Floor, Century City Mall, Kalayaan Avenu... | Century City Mall, Poblacion, Makati City | Century City Mall, Poblacion, Makati City, Mak... | 121.027535 | 14.565443 | French, Japanese, Desserts | ... | Yes | No | No | No | 3 | 4.8 | Dark Green | Excellent | 314 | Phillipines |
| 1 | 6304287 | Izakaya Kikufuji | 162 | Makati City | Little Tokyo, 2277 Chino Roces Avenue, Legaspi... | Little Tokyo, Legaspi Village, Makati City | Little Tokyo, Legaspi Village, Makati City, Ma... | 121.014101 | 14.553708 | Japanese | ... | Yes | No | No | No | 3 | 4.5 | Dark Green | Excellent | 591 | Phillipines |
| 2 | 6300002 | Heat - Edsa Shangri-La | 162 | Mandaluyong City | Edsa Shangri-La, 1 Garden Way, Ortigas, Mandal... | Edsa Shangri-La, Ortigas, Mandaluyong City | Edsa Shangri-La, Ortigas, Mandaluyong City, Ma... | 121.056831 | 14.581404 | Seafood, Asian, Filipino, Indian | ... | Yes | No | No | No | 4 | 4.4 | Green | Very Good | 270 | Phillipines |
| 3 | 6318506 | Ooma | 162 | Mandaluyong City | Third Floor, Mega Fashion Hall, SM Megamall, O... | SM Megamall, Ortigas, Mandaluyong City | SM Megamall, Ortigas, Mandaluyong City, Mandal... | 121.056475 | 14.585318 | Japanese, Sushi | ... | No | No | No | No | 4 | 4.9 | Dark Green | Excellent | 365 | Phillipines |
| 4 | 6314302 | Sambo Kojin | 162 | Mandaluyong City | Third Floor, Mega Atrium, SM Megamall, Ortigas... | SM Megamall, Ortigas, Mandaluyong City | SM Megamall, Ortigas, Mandaluyong City, Mandal... | 121.057508 | 14.584450 | Japanese, Korean | ... | Yes | No | No | No | 4 | 4.8 | Dark Green | Excellent | 229 | Phillipines |
5 rows × 22 columns
restaurants.Country.value_counts()
India 8643 United States 419 United Kingdom 80 Brazil 60 South Africa 60 UAE 60 New Zealand 40 Turkey 34 Australia 24 Phillipines 22 Indonesia 21 Qatar 20 Singapore 20 Sri Lanka 20 Canada 4 Name: Country, dtype: int64
indiaRes=restaurants[restaurants['Country']=='India']
singaporeRes=restaurants[restaurants['Country']=='Singapore']
AusRes=restaurants[restaurants['Country']=='Australia']
BrazRes=restaurants[restaurants['Country']=='Brazil']
CanadaRes=restaurants[restaurants['Country']=='Canada']
UAERes=restaurants[restaurants['Country']=='UAE']
UKRes=restaurants[restaurants['Country']=='United Kingdom']
USRes=restaurants[restaurants['Country']=='United States']
SouthAfricaRes=restaurants[restaurants['Country']=='South Africa']
NewZelandRes=restaurants[restaurants['Country']=='New Zealand']
TurkeyRes=restaurants[restaurants['Country']=='Turkey']
IndonesiaRes=restaurants[restaurants['Country']=='Indonesia']
QatarRes=restaurants[restaurants['Country']=='Qatar']
SrilankaRes=restaurants[restaurants['Country']=='Sri Lanka']
indiaRes.head()
| Restaurant ID | Restaurant Name | Country Code | City | Address | Locality | Locality Verbose | Longitude | Latitude | Cuisines | ... | Has Table booking | Has Online delivery | Is delivering now | Switch to order menu | Price range | Aggregate rating | Rating color | Rating text | Votes | Country | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 609 | 3400025 | Jahanpanah | 1 | Agra | E 23, Shopping Arcade, Sadar Bazaar, Agra Cant... | Agra Cantt | Agra Cantt, Agra | 78.011544 | 27.161661 | North Indian, Mughlai | ... | No | No | No | No | 3 | 3.9 | Yellow | Good | 140 | India |
| 610 | 3400341 | Rangrezz Restaurant | 1 | Agra | E-20, Shopping Arcade, Sadar Bazaar, Agra Cant... | Agra Cantt | Agra Cantt, Agra | 0.000000 | 0.000000 | North Indian, Mughlai | ... | No | No | No | No | 2 | 3.5 | Yellow | Good | 71 | India |
| 611 | 3400005 | Time2Eat - Mama Chicken | 1 | Agra | Main Market, Sadar Bazaar, Agra Cantt, Agra | Agra Cantt | Agra Cantt, Agra | 78.011608 | 27.160832 | North Indian | ... | No | No | No | No | 2 | 3.6 | Yellow | Good | 94 | India |
| 612 | 3400021 | Chokho Jeeman Marwari Jain Bhojanalya | 1 | Agra | 1/48, Delhi Gate, Station Road, Raja Mandi, Ci... | Civil Lines | Civil Lines, Agra | 77.998092 | 27.195928 | Rajasthani | ... | No | No | No | No | 2 | 4.0 | Green | Very Good | 87 | India |
| 613 | 3400017 | Pinch Of Spice | 1 | Agra | 23/453, Opposite Sanjay Cinema, Wazipura Road,... | Civil Lines | Civil Lines, Agra | 78.007553 | 27.201725 | North Indian, Chinese, Mughlai | ... | No | No | No | No | 3 | 4.2 | Green | Very Good | 177 | India |
5 rows × 22 columns
indiaRes.City.value_counts()
New Delhi 5473 Gurgaon 1118 Noida 1080 Faridabad 251 Ghaziabad 25 Ahmedabad 21 Guwahati 21 Lucknow 21 Bhubaneshwar 21 Amritsar 21 Goa 20 Surat 20 Ludhiana 20 Kochi 20 Vadodara 20 Aurangabad 20 Jaipur 20 Mangalore 20 Coimbatore 20 Chennai 20 Nashik 20 Bangalore 20 Pune 20 Mysore 20 Patna 20 Vizag 20 Kolkata 20 Ranchi 20 Nagpur 20 Puducherry 20 Bhopal 20 Indore 20 Mumbai 20 Allahabad 19 Dehradun 19 Chandigarh 18 Hyderabad 18 Kanpur 18 Varanasi 18 Agra 17 Secunderabad 2 Mohali 1 Panchkula 1 Name: City, dtype: int64
DelhiTopRes=indiaRes[(indiaRes['City']=='New Delhi')&(indiaRes['Aggregate_rating']>4.5)][['Aggregate_rating','Restaurant_Name','Votes']].sort_values(ascending=False,by='Votes')
DelhiTopRes
| Aggregate_rating | Restaurant_Name | Votes | |
|---|---|---|---|
| 2991 | 4.9 | Naturals Ice Cream | 2620 |
| 3579 | 4.9 | Indian Accent - The Manor | 1934 |
| 6637 | 4.6 | The California Boulevard | 1691 |
| 4617 | 4.6 | Big Chill | 1569 |
| 6975 | 4.7 | Echoes Satyaniketan | 1563 |
| 7827 | 4.6 | Cafeteria & Co. | 1136 |
| 3288 | 4.6 | Spezia Bistro | 1071 |
| 6635 | 4.7 | Naturals Ice Cream | 474 |
| 4276 | 4.9 | Masala Library | 408 |
| 3710 | 4.6 | Tashan | 304 |
| 7045 | 4.7 | Pa Pa Ya | 268 |
| 2992 | 4.7 | Zabardast Indian Kitchen | 242 |
| 6633 | 4.6 | Band Baaja Baaraat | 128 |
| 7158 | 4.6 | Greenr Cafe | 112 |
| 6634 | 4.8 | Kopper Kadai | 83 |
| 6404 | 4.6 | Food Scouts | 61 |
| 2990 | 4.7 | MOB Brewpub | 52 |
DelhiTopRes.style.apply(lambda x: ['background: green' if x.name == 'Votes' else 'background: lightsteelblue' for i in x])
| Aggregate_rating | Restaurant_Name | Votes | |
|---|---|---|---|
| 2991 | 4.900000 | Naturals Ice Cream | 2620 |
| 3579 | 4.900000 | Indian Accent - The Manor | 1934 |
| 6637 | 4.600000 | The California Boulevard | 1691 |
| 4617 | 4.600000 | Big Chill | 1569 |
| 6975 | 4.700000 | Echoes Satyaniketan | 1563 |
| 7827 | 4.600000 | Cafeteria & Co. | 1136 |
| 3288 | 4.600000 | Spezia Bistro | 1071 |
| 6635 | 4.700000 | Naturals Ice Cream | 474 |
| 4276 | 4.900000 | Masala Library | 408 |
| 3710 | 4.600000 | Tashan | 304 |
| 7045 | 4.700000 | Pa Pa Ya | 268 |
| 2992 | 4.700000 | Zabardast Indian Kitchen | 242 |
| 6633 | 4.600000 | Band Baaja Baaraat | 128 |
| 7158 | 4.600000 | Greenr Cafe | 112 |
| 6634 | 4.800000 | Kopper Kadai | 83 |
| 6404 | 4.600000 | Food Scouts | 61 |
| 2990 | 4.700000 | MOB Brewpub | 52 |
sns.jointplot('Votes','Aggregate_rating',data=DelhiTopRes)
<seaborn.axisgrid.JointGrid at 0x1d83e6a8948>
There is a bit linear relationship between rating and the votes although not much, voting influences the rating
India=indiaRes['Restaurant_Name'].nunique()
India
6595
DelhiTopResOnline=indiaRes[(indiaRes['City']=='New Delhi')&(indiaRes['Aggregate_rating']>4.5) &(indiaRes['Has_Online_delivery']=='Yes')][['Aggregate_rating','Restaurant_Name','Votes','Has_Online_delivery']].sort_values(ascending=False,by='Votes')
DelhiTopResOnline.style.apply(lambda x: ['background: green' if x.name == 'Has_Online_delivery' else 'background: Royalblue' for i in x])
| Aggregate_rating | Restaurant_Name | Votes | Has_Online_delivery | |
|---|---|---|---|---|
| 2991 | 4.900000 | Naturals Ice Cream | 2620 | Yes |
| 3288 | 4.600000 | Spezia Bistro | 1071 | Yes |
| 6635 | 4.700000 | Naturals Ice Cream | 474 | Yes |
| 2992 | 4.700000 | Zabardast Indian Kitchen | 242 | Yes |
| 7158 | 4.600000 | Greenr Cafe | 112 | Yes |
| 6404 | 4.600000 | Food Scouts | 61 | Yes |
Lets check which country is providing most online delivery option
sns.set(rc={'figure.figsize':(20,11)})
sns.countplot(restaurants['Country'],hue=restaurants['Has_Online_delivery'])
C:\Users\TOSHIBA\anaconda3\lib\site-packages\seaborn\_decorators.py:43: FutureWarning: Pass the following variable as a keyword arg: x. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation. FutureWarning
<AxesSubplot:xlabel='Country', ylabel='count'>
Look for the cheap but best restaurants available in a New Delhi
New_Delhi=indiaRes[(indiaRes['City']=='New Delhi')&(indiaRes['Aggregate_rating']>4.5)&(indiaRes['Votes']>500)][['Average_Cost_for_two','Restaurant_Name','Aggregate_rating','Votes']].sort_values(ascending=True,by=['Average_Cost_for_two']).head()
New_Delhi
| Average_Cost_for_two | Restaurant_Name | Aggregate_rating | Votes | |
|---|---|---|---|---|
| 2991 | 150.0 | Naturals Ice Cream | 4.9 | 2620 |
| 6975 | 600.0 | Echoes Satyaniketan | 4.7 | 1563 |
| 3288 | 900.0 | Spezia Bistro | 4.6 | 1071 |
| 7827 | 900.0 | Cafeteria & Co. | 4.6 | 1136 |
| 4617 | 1500.0 | Big Chill | 4.6 | 1569 |
IndianCuisines=restaurants[restaurants['Country']=='India']['Cuisines'].value_counts().head()
IndianCuisines
North Indian 936 North Indian, Chinese 511 Fast Food 348 Chinese 340 North Indian, Mughlai 334 Name: Cuisines, dtype: int64
table=pd.pivot_table(data=indiaRes, index = ('City'), values="Aggregate_rating")
cm = sns.light_palette("green", as_cmap=True)
table.style.background_gradient(cmap=cm,axis=0)
| Aggregate_rating | |
|---|---|
| City | |
| Agra | 3.917647 |
| Ahmedabad | 4.161905 |
| Allahabad | 3.400000 |
| Amritsar | 3.685714 |
| Aurangabad | 3.375000 |
| Bangalore | 4.375000 |
| Bhopal | 3.950000 |
| Bhubaneshwar | 3.980952 |
| Chandigarh | 4.050000 |
| Chennai | 4.315000 |
| Coimbatore | 4.135000 |
| Dehradun | 4.036842 |
| Faridabad | 1.866932 |
| Ghaziabad | 2.852000 |
| Goa | 4.245000 |
| Gurgaon | 2.651431 |
| Guwahati | 4.190476 |
| Hyderabad | 4.344444 |
| Indore | 3.970000 |
| Jaipur | 4.130000 |
| Kanpur | 3.822222 |
| Kochi | 4.080000 |
| Kolkata | 4.255000 |
| Lucknow | 4.195238 |
| Ludhiana | 3.980000 |
| Mangalore | 3.745000 |
| Mohali | 4.300000 |
| Mumbai | 4.085000 |
| Mysore | 3.695000 |
| Nagpur | 3.965000 |
| Nashik | 3.520000 |
| New Delhi | 2.438845 |
| Noida | 2.036204 |
| Panchkula | 4.200000 |
| Patna | 3.455000 |
| Puducherry | 3.730000 |
| Pune | 4.220000 |
| Ranchi | 3.455000 |
| Secunderabad | 4.500000 |
| Surat | 3.935000 |
| Vadodara | 4.025000 |
| Varanasi | 3.494444 |
| Vizag | 4.005000 |
Calculating the restaurants rating based on the rating text with percentage
indiaRes["Rating_text"].value_counts()
Average 3677 Not rated 2139 Good 1841 Very Good 691 Poor 180 Excellent 115 Name: Rating_text, dtype: int64
sns.boxplot(indiaRes["Rating_text"],indiaRes["Average_Cost_for_two"])
C:\Users\TOSHIBA\anaconda3\lib\site-packages\seaborn\_decorators.py:43: FutureWarning: Pass the following variables as keyword args: x, y. From version 0.12, the only valid positional argument will be `data`, and passing other arguments without an explicit keyword will result in an error or misinterpretation. FutureWarning
<AxesSubplot:xlabel='Rating_text', ylabel='Average_Cost_for_two'>
The plot shows rating does influence the cost of a restaurant
plt.figure(figsize=(10,10))
indiaRes['City'].value_counts().head().plot(kind='pie',autopct='%1.1f%%')
<matplotlib.axes._subplots.AxesSubplot at 0x1fb5a0d03c8>
plt.figure(figsize=(10,10))
indiaRes['Cuisines'].value_counts().head(10).plot(kind='pie',autopct='%1.1f%%')
<AxesSubplot:ylabel='Cuisines'>
import pandas_profiling as pp
pp.ProfileReport(indiaRes)